//
//  AppDelegate+AutoSubscribeNotification.m
//  Quiz&Crossword
//
//  Created by 左维杰 on 2018/2/3.
//  Copyright © 2018年 左维杰. All rights reserved.
//

#import "AppDelegate+IAPNotification.h"

@implementation AppDelegate (IAPNotification)


- (BOOL)IAPApplication:(UIApplication *)application
   didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(purchasedDidFinished) name:kSRProductPurchasedNotification object:nil];
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(progressDismiss) name:kSRProductPurchasedFailNotification object:nil];
    
    
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(progressDismiss) name:kSRProductRestoredNotification object:nil];
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(progressDismiss) name:kSRProductRestoreDidSuccessNotification object:nil];
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(progressDismiss) name:kSRProductRestoreDidFailedNotification object:nil];
    
    return YES;
}

#pragma mark - notification
-(void)purchasedDidFinished
{
    //保存本地记录
    [[NSUserDefaults standardUserDefaults] setObject:@(YES) forKey:@"PurchasedOK"];
    [[NSUserDefaults standardUserDefaults] synchronize];
}

@end
